#3d points transform
import numpy as np
def points3D_transform(points1,points2):
    '''points1 m*3 points2 n*3  m=n'''
    center_points1=np.mean(points1,0)
    center_points2=np.mean(points2,0)
    new_points1=points1-np.tile(center_points1,(points1.shape[0],1))
    new_points2=points2-np.tile(center_points2,(points2.shape[0],1))
    M=new_points2.T @ new_points1 #3*3 向量化编程，拒绝循环
    u,s,vt=np.linalg.svd(M)
    R=u@vt
    if np.linalg.det(R)<0:
        R=-R
    T=center_points2.T-R@center_points1
    return R,T